<template>
  <TableView
    ref="tableView"
    :table-attrs="{
      api: fetchList,
      descs: ['create_time'],
      dicOptions: [{ prop: 'status', dicType: 'room_land_status' }]
    }"
    form-path="/space/roomland/roomLandForm/{id:-1}"
    :search-model="searchForm"
    :delete-api="batchDelete"
    :toolbar-attrs="{
      buttons: ['slot', { del: permissions.roomland_fyroomland_del, create: permissions.roomland_fyroomland_add }]
    }">
    <template #toolbar-button>
      <ToolbarButton
        v-if="permissions.roomland_fyroomland_export"
        type="primary"
        icon="el-icon-download"
        label="导出"
        @click="exportExcel()" />
    </template>
    <template #columns>
      <TableColumn label="资产名称" clickable prop="assetName" width="145" />
      <TableColumn label="资产编号" clickable prop="assetNumber" width="145" />
      <TableColumn label="登记日期" prop="registrationDate" width="105" />
      <TableColumn label="使用状况" prop="status" />
      <TableColumn label="土地编号" prop="landNumber" width="158" />
      <TableColumn label="坐落位置" prop="location" width="135" />
      <TableColumn label="使用权类型" prop="usufructType" width="130" />
      <TableColumn label="取得方式" prop="acquireWay" />
      <TableColumn label="批准用途" prop="permittedUse" />
      <TableColumn label="实际用途" prop="practicalUse" />
      <TableColumn label="使用年限" prop="usefulLife" />
      <TableColumn label="取得日期" prop="builddate" width="105" />
      <TableColumn label="权属性质" prop="ownershipType" />
      <TableColumn label="权属证明" prop="ownershipProve" />
      <TableColumn label="权属证号" prop="ownershipNumber" />
      <TableColumn label="产权形式" prop="propertyType" />
      <TableColumn label="总面积" prop="overallFloorage" />
      <TableColumn label="权属面积" prop="ownershipArea" />
      <TableColumn label="基本地价" prop="landPrice" />
      <TableColumn label="发证日期" prop="issueDate" width="105" />
      <TableColumn label="使用证号" prop="landusagePermit" />
      <TableColumn label="经度" prop="x" />
      <TableColumn label="纬度" prop="y" />
      <TableColumn label="备注" prop="remarks" />
    </template>
    <template #search-form>
      <FormInput v-model="searchForm.assetName" label="资产名称" prop="assetName" />
      <FormInput v-model="searchForm.assetNumber" label="资产编号" prop="assetNumber" />
      <FormDatePicker
        v-model="searchForm.registrationDate"
        label="登记日期"
        :split="false"
        date-range
        prop="registrationDate" />
      <FormSelect v-model="searchForm.status" prop="status" dict-type="room_land_status" label="使用状况" />
      <FormInput v-model="searchForm.landNumber" label="土地编号" prop="landNumber" />
      <FormInput v-model="searchForm.location" label="坐落位置" prop="location" />
      <FormInput v-model="searchForm.landusagePermit" label="使用证号" prop="landusagePermit" />
    </template>
  </TableView>
</template>

<script>
  import { mapState } from 'vuex'
  import { fetchList, batchDelete } from '@/api/space/fyroomland'
  import { services } from '@/config'

  export default {
    name: 'RoomLandView',
    data() {
      return {
        searchForm: {
          assetName: '',
          assetNumber: '',
          registrationDate: [],
          status: '',
          landNumber: '',
          location: '',
          landusagePermit: ''
        }
      }
    },
    computed: {
      ...mapState('user', ['permissions'])
    },
    methods: {
      batchDelete,
      fetchList,
      exportExcel() {
        this.$downBlobFile(
          `${services.spaceService}fyroomland/export`,
          this.searchForm,
          `土地管理${this.$dateFormat(new Date())}.xlsx`
        )
      }
    }
  }
</script>
